package com.hzhr.extdevice.controller;

import com.hzhr.extdevice.aspect.Author;
import com.hzhr.extdevice.constant.ReturnCodeConst;
import com.hzhr.extdevice.model.database.*;
import com.hzhr.extdevice.model.response.BaseResponse;
import com.hzhr.extdevice.util.StringHelper;
import com.hzhr.extdevice.util.TConverter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@Api(value="远程设备接口",description = "远程设备接口")
@RestController
@RequestMapping("gascompany-id/{gid}/equipiot")
public class EquipiotController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());


    @ApiOperation(value = "新增远传设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceid", dataType = "String", paramType = "query", required = true, value = "设备编号(最大36和字符)"),
            @ApiImplicitParam(name = "type", dataType = "int", paramType = "query", required = true, value = "设备类型,参考数据字典设备类型(SBLX)"),
            @ApiImplicitParam(name = "address", dataType = "String", paramType = "query", required = false, value = "安装地址,最大50个字符"),
            @ApiImplicitParam(name = "longitude", dataType = "double", paramType = "query", required = false, value = "经度，保留6位小数以百度地图为准116.339878(地球仪东西方向为经)"),
            @ApiImplicitParam(name = "latitude", dataType = "double", paramType = "query", required = false, value = "纬度，保留6位小数以百度地图为准39.954105(地球仪南北方向为纬)"),
            @ApiImplicitParam(name = "imgUrls", dataType = "String[]", paramType = "query", required = false, value = "照片路径列表，多个请使用逗号分隔")
    })
    @Author
    @RequestMapping(value = "add", method = RequestMethod.POST)
    public Object add(@RequestParam(value = "deviceid", required = true) String deviceid,
                      @RequestParam(value = "type", required = true) int type,
                      @RequestParam(value = "address", required = false, defaultValue = "") String address,
                      @RequestParam(value = "longitude", required = false, defaultValue = "0") double longitude,
                      @RequestParam(value = "latitude", required = false, defaultValue = "0") double latitude,
                      @RequestParam(value = "imgUrls", required = false) String[] imgUrls) throws Exception {

        return new BaseResponse(ReturnCodeConst.SUCCESS, "成功", "");
    }


    @ApiOperation(value = "修改远传设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceid", dataType = "String", paramType = "query", required = true, value = "设备编号(最大36个字符)"),
            @ApiImplicitParam(name = "type", dataType = "int", paramType = "query", required = true, value = "设备类型,参考数据字典设备类型(SBLX)"),
            @ApiImplicitParam(name = "address", dataType = "String", paramType = "query", required = false, value = "安装地址,最大50个字符"),
            @ApiImplicitParam(name = "longitude", dataType = "double", paramType = "query", required = false, value = "经度，保留6位小数以百度地图为准116.339878(地球仪东西方向为经)"),
            @ApiImplicitParam(name = "latitude", dataType = "double", paramType = "query", required = false, value = "纬度，保留6位小数以百度地图为准39.954105(地球仪南北方向为纬)"),
            @ApiImplicitParam(name = "imgUrls", dataType = "String[]", paramType = "query", required = false, value = "照片路径列表，多个请使用逗号分隔")
    })
    @Author
    @RequestMapping(value = "mod", method = RequestMethod.POST)
    public Object mod(@RequestParam(value = "deviceid", required = true) String deviceid,
                      @RequestParam(value = "type", required = true) int type,
                      @RequestParam(value = "address", required = false, defaultValue = "") String address,
                      @RequestParam(value = "longitude", required = false, defaultValue = "0") Double longitude,
                      @RequestParam(value = "latitude", required = false, defaultValue = "0") Double latitude,
                      @RequestParam(value = "imgUrls", required = false) String[] imgUrls) throws Exception {

        return new BaseResponse(ReturnCodeConst.SUCCESS, "成功", "");
    }


    @ApiOperation(value = "删除远传设备")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceid", dataType = "String", paramType = "query", required = true, value = "设备编号(最大36个字符)")})
    @Author
    @RequestMapping(value = "del", method = RequestMethod.POST)
    public Object del(@RequestParam(value = "deviceid", required = true) String deviceid) throws Exception {
        return new BaseResponse(ReturnCodeConst.SUCCESS, "成功", "");
    }
}
